class TaskXMLBuilder

  def write2XML tasks,path
    xml=Builder::XmlMarkup.new :indent=>1   
    xml.instruct!
    xml.SmarTask{
      tasks.each do |task|
        xml.task(task.comment, 
    			"id" => task.id,
    			"name" => task.name,
    			"start_time" => task.startTime,
    			"deadline" => task.deadline,
          "status" => task.status, 
          "parent_id" =>task.parentId
          )
      end
    }
    path = "my_task.xml" if path == nil
		if GLib.os_win32?
			path = GLib::Win32.locale_filename_from_utf8 path
		else
			path = GLib.filename_from_utf8 path
		end
    xml_str=xml.target!   
    open(path,'w') do |f|
      f.puts xml_str   
    end
  end
  
  def changeLanguage language,path
		xml=Builder::XmlMarkup.new :indent=>1
    xml.instruct!
    xml.SmarTask{
			xml.Local(nil,"language" => language)
    }
		path = "configure.xml" if path == nil
		if GLib.os_win32?
			path = GLib::Win32.locale_filename_from_utf8 path
		else
			path = GLib.filename_from_utf8 path
		end
    xml_str=xml.target!   
    open(path,'w') do |f|
      f.puts xml_str   
    end
  end
end
